All Questions
19 questions
2votes
1answer
109views
Optimizing minHeap implementation
I have implemented a java class for minHeap but it is not working as fast as I want . I want some help to change it to work faster in insertion or deleting the minimum node. Here is my implementation:...
4votes
1answer
199views
Parsing weather station XML on raspberry pi
This if for a school project that is all about getting the most performance possible out of a relatively weak computer. For this project we have received a weather station report generator that ...
1vote
2answers
290views
Optimize printing massive strings to System.out with respect to time
I need to cut the time it takes to print a large string by ~50%. I went from using s1 + s2 to using StringBuilder, and instead ...
0votes
2answers
2kviews
Data structure to count occurrences of words
I have some code for a assignment where the main marks are awarded based on efficiency. The program uses a given wordgenerator which generates random words and adds them to a user-made data structure. ...
2votes
2answers
178views
My spaceship is slow to explode after being hit by the asteroid
I am making a game for my computer science class. My professor's requirements are: Write a Processing program that draws a triangle in the middle of the window. Rotate the triangle when the left and ...
13votes
5answers
4kviews
Enter my Matrix
Here is my next Java assignment: create a Matrix class that can add and multiply two matrices together. I was given some code as a skeleton and then fleshed it out ...
6votes
3answers
2kviews
Optimizing this Knight's Tour
My assignment in CS was to make a knight's tour application that could solve the problem from any starting position. I had just finished the code so excuse the lack of deeply descriptive comments. My ...
8votes
2answers
3kviews
Finding the longest Collatz sequence cycle
I wrote a program to calculate Collatz sequences for initial numbers between 1 and a given integer i, then find the one with the largest cycle length. My code is ...
3votes
1answer
233views
Hangman game background image possibly inefficient
I'm making a Hangman game and it seems that my code doesn't provide me much freedom with using layouts. I added an image to my JFrame then I added a ...
0votes
1answer
121views
Processing a string from the console
How can I make this program run faster? On enter, I have a string from the console. For example: 1 1 7 3 2 0 0 4 5 5 6 2 1 On exit, it will be ...
2votes
2answers
1kviews
In-order Predecessor BST review
I was referred here from StackOverflow, so here is what I posted over there: So, for an assignment, I have to construct a binary search tree, plus an assortment of related functions. I have them all ...
5votes
1answer
4kviews
How is my quarterly sales statistics program?
Am I making good use of a 2-D array? Is this code inefficient? I am supposed to receive input from 6 departments for 4 quarterly periods in Java. My assignment asks: Quarterly Sales Statistics ...
3votes
3answers
4kviews
Approximating sines and cosines using up to five terms of the Taylor series
I have one programming question: The sine and cosine of \$x\$ can be computed as follows: \$\sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \frac{x^9}{9!} - \dots\$ ...
4votes
2answers
2kviews
Searching through a contact list for given criteria
I have been staring at this code for awhile now and I am thinking there is a way to optimize it (namely the if-else statement ...
1vote
3answers
279views
Primes Tester for speed performance
I was given a homework assignment in Java to create classes that find Prime number and etc (you will see in code better). ...